﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.Domain.Users;
using Traceability.Services;
using Traceability.Services.UserServices;

namespace Traceability.Webapi.Controllers
{
    /// <summary>
    /// This is the controller for managing user accounts.
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AccountsController : ControllerBase
    {
        private readonly IAccountService _accountService;

        /// <summary>
        /// goes through the constructor to initialize the account service.
        /// </summary>
        /// <param name="accountService"></param>
        public AccountsController(IAccountService accountService)
        {
            _accountService = accountService;
        }
        /// <summary>
        /// This method is used to register a new user.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        [HttpGet]
        public Task <APIResult<Account>>Login(string username, string password)
        {
            return _accountService.Login(username, password);
        }
    }
}
